package oop.ex3.serverprotocol;

import java.io.DataInputStream;
import java.io.DataOutputStream;

import oop.ex3.nameserver.NameServer;
import oop.ex3.sharedclasses.IPaddress;

/**
 * Handles ENDSESSION Message.
 * handles a client's request to end the current communication session,
 * for example - after notifying a server of containing a new file.
 * 
 * @author zablo
 *
 */
public class EndSession extends ClientMessageHandler{

	@Override
	public boolean run(NameServer server, IPaddress sessionIP,
			DataInputStream clientInput, DataOutputStream clientOutput) {
		
		if (endsWithEnd(clientInput)==FAILURE){
			return FAILURE;
		}
		
		if (ServerMessageSender.done(clientOutput)==FAILURE){
			return FAILURE;
		}
		
		return SUCCESS;
	}

}
